"""
__author__ = 'heyanmin'
__time__ = '2021/8/7 5:58 下午'
"""
"""入栈 出栈，顺序取出元素
索引
"""
#两数之和,方法一
class Solution:
    # 线性查找
    def twoSum(self,nums,target):
        for i in range(len(nums)):
            x = nums[i]
            for j in range(i+1,len(nums)):
                if j == target-x:
                    return [i,j]
        return []

    # 二分查找：有序序列可使用
if __name__ == '__main__':
    so = Solution()
    nums = [1, 2, 3, 4]
    target = 5
    print(so.twoSum(nums,target))
